<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <ul id="city"></ul>
    <script>
        var cityList = ["北京","上海","深圳"];
        for (var idx in cityList){
            var text = cityList[idx];
            //创建<li></li>标签
            var tag = document.createElement("li");
            //在li标签中写入内容
            tag.innerText = text;
            //添加到id=city的标签里面。DOM
            var parentTag = document.getElementById("city");
            parentTag.appendChild(tag);
            };
    </script>
</body>
</html>